package com.soar.recruitment.common.util;

import android.text.TextUtils;

public class ValidityUtils {

    private static final String PHONE_CHECK = "^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\\d{8}$";
    private static final String EMAIL_CHECK = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    public static final String ALL_NUMBER = "^[0-9]{6,20}$";
    public static final String ALL_LETTER = "^[a-zA-Z]{6,20}$";
    
    public static boolean checkEmail(String email) {

        if (!TextUtils.isEmpty(email) && email.matches(EMAIL_CHECK)) {
            return true;
        }
        return false;
    }

    public static boolean checkPhone(String phone) {
        if (!TextUtils.isEmpty(phone) && phone.matches(PHONE_CHECK)) {
            return true;
        }
        return false;
    }
    
    /**
     * 判断密码是否全是数字
     * @param password 密码
     */
    public static boolean checkPasswordNumber(String password) {
        if (!TextUtils.isEmpty(password) && password.matches(ALL_NUMBER)) {
            return true;
        }
        return false;
    }
    /**
     * 判断密码是否是必须含有字母，可以包含数字
     * @param password 密码
     */
    public static boolean checkPasswordLetter(String password) {
        if (!TextUtils.isEmpty(password) && password.matches(ALL_LETTER)) {
            return true;
        }
        return false;
    }

}
